<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <script src="./lib/vue.js"></script>
    </head>
    <body>
        <div id="app">
            <h1>{{ msg }}</h1>
            <h1>{{ reverseMsg }}</h1>
            <ul>
                <li v-for="item in arr">
                    {{ item }}
                </li>
            </ul>
        </div>
    </body>
    <script>
        var app = new Vue({
            el:"#app",
            data:{
                msg:"hello Vue",
                arr:["小明","小红","小强"]
            },
            computed: {
                reverseMsg:{
                    // get: 得到   正常是直接写get  return里面的  不用写get
                    get:function(){
                        return this.msg.split("").reverse().join("")
                    },
                    // set: 设置  修改需要传值value 
                    set:function(value){ 
                        console.log(value);
                        this.msg = value.split("").reverse().join("")
                    }
                }
            },
            // 尽量不使用监听  watch   
            watch: {
                msg:function(val){
                    console.log("监听事件---msg   侦听器");
                    console.log(val);
                },
                arr:function(val){
                    console.log("监听事件---arr   侦听器");
                    this.msg = "监听事件---arr   侦听器";
                    console.log(val);
                }
            }
        })
    </script>
</html>